<?php 
$i= 0;
if(isset($_POST["TacheRealise"]) && isset($_POST["Echeance"])
		 && isset($_POST["Responsable"]) && isset($_POST["NatureDepense"])
		 && isset($_POST["BudgetDepense"]) && isset($_POST["Fournisseur"]) 
		 && isset($_POST["NatureRecette"]) && isset($_POST["BudgetRecette"]) 
		 && isset($_POST["PointPositif"]) && isset($_POST["PointNegatif"]) 
		 && isset($_POST["BonASavoir"]) && isset($_POST["Suggestion"]))
{
	if(!empty($_POST["TacheRealise"]))
	{
		$tacheRealise = $_POST["TacheRealise"];
		foreach($tacheRealise as $t)
		{
			if(empty($t))
			{
				$_POST["erreur"]="erreur";
				$_SESSION["erreur"][$i]="Champ Tâche vide";
				$i++;
			}
		}
		if(!empty($_POST["Echeance"]))
		{
			$echeance = $_POST["Echeance"];
			foreach($echeance as $t)
			{
				if(empty($t))
				{
					$_SESSION["erreur"][$i]="Champ echeance vide";
					$i++;
				}
			}
			if(!empty($_POST["Responsable"]))
			{
				$responsable = $_POST["Responsable"];
				foreach($responsable as $t)
				{
					if(empty($t))
					{
						$_SESSION["erreur"][$i]="Champ responsable vide";
						$i++;
					}
				}
				if(!empty($_POST["NatureDepense"]))
				{
					$naturedepense = $_POST["NatureDepense"];
					foreach($naturedepense as $t)
					{
						if(empty($t))
						{
							$_SESSION["erreur"][$i]="Champ Nature(dépense) vide";
							$i++;
						}
					}
					if(!empty($_POST["BudgetDepense"]))
					{
						$budgetdepense = $_POST["BudgetDepense"];
						foreach($budgetdepense as $t)
						{
							if(empty($t))
							{
								$_SESSION["erreur"][$i]="Champ budget(dépense) vide";
								$i++;
							}
						}
						if(!empty($_POST["Fournisseur"]))
						{
							$fournisseur = $_POST["Fournisseur"];
							foreach($fournisseur as $t)
							{
								if(empty($t))
								{
									$_SESSION["erreur"][$i]="Champ fournisseur vide";
									$i++;
								}
							}
							if(!empty($_POST["NatureRecette"]))
							{
								$naturerecette = $_POST["NatureRecette"];
								foreach($naturerecette as $t)
								{
									if(empty($t))
									{
										$_SESSION["erreur"][$i]="Champ Nature(recette) vide";
										$i++;
									}
								}
								if(!empty($_POST["BudgetRecette"]))
								{
									$budgetrecette = $_POST["BudgetRecette"];
									foreach($budgetrecette as $t)
									{
										if(empty($t))
										{
											$_SESSION["erreur"][$i]="Champ budget(recette) vide";
										$i++;
										}
									}									
								}
							}
						}
					}
				}
			}	
		}		
	}
}
if(isset($_SESSION["erreur"]))
{
	echo "Des erreurs sont survenues !";
	echo '<form method="post" action="index.php?module=actionComm&action=remplirFormulaire">
			<p>';
			foreach($tacheRealise as $t)
			{
				echo '<input type="hidden" name="TacheRealise[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($echeance as $t)
			{
				echo '<input type="hidden" name="Echeance[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($responsable as $t)
			{
				echo '<input type="hidden" name="Responsable[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($naturedepense as $t)
			{
				echo '<input type="hidden" name="NatureDepense[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($budgetdepense as $t)
			{
				echo '<input type="hidden" name="BudgetDepense[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($fournisseur as $t)
			{
				echo '<input type="hidden" name="Fournisseur[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($naturerecette as $t)
			{
				echo '<input type="hidden" name="NatureRecette[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<p>';
			foreach($budgetrecette as $t)
			{
				echo '<input type="hidden" name="BudgetRecette[]" value="'.$t.'" />';
			}
	echo   '</p>';
	echo   '<input type="submit" name="corriger" value="Retour au formulaire"/>
			</p>
		  </form>';
}
else
	header("Location: index.php?module=actionComm&action=generation");